package com.ruoyi.web.tdm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdm.domain.TdmSePuZhiShiKu;
import com.ruoyi.web.tdm.service.ITdmSePuZhiShiKuService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 色谱知识库管理Controller
 * 
 * @author ly
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/tdm/TdmSePuZhiShiKu")
public class TdmSePuZhiShiKuController extends BaseController
{
    @Autowired
    private ITdmSePuZhiShiKuService tdmSePuZhiShiKuService;

    /**
     * 查询色谱知识库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmSePuZhiShiKu:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmSePuZhiShiKu tdmSePuZhiShiKu)
    {
        startPage();
        List<TdmSePuZhiShiKu> list = tdmSePuZhiShiKuService.selectTdmSePuZhiShiKuList(tdmSePuZhiShiKu);
        return getDataTable(list);
    }

    /**
     * 导出色谱知识库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmSePuZhiShiKu:export')")
    @Log(title = "色谱知识库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmSePuZhiShiKu tdmSePuZhiShiKu)
    {
        List<TdmSePuZhiShiKu> list = tdmSePuZhiShiKuService.selectTdmSePuZhiShiKuList(tdmSePuZhiShiKu);
        ExcelUtil<TdmSePuZhiShiKu> util = new ExcelUtil<TdmSePuZhiShiKu>(TdmSePuZhiShiKu.class);
        util.exportExcel(response, list, "色谱知识库管理数据");
    }

    /**
     * 获取色谱知识库管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmSePuZhiShiKu:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmSePuZhiShiKuService.selectTdmSePuZhiShiKuById(id));
    }

    /**
     * 新增色谱知识库管理
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmSePuZhiShiKu:add')")
    @Log(title = "色谱知识库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmSePuZhiShiKu tdmSePuZhiShiKu)
    {
        return toAjax(tdmSePuZhiShiKuService.insertTdmSePuZhiShiKu(tdmSePuZhiShiKu));
    }

    /**
     * 修改色谱知识库管理
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmSePuZhiShiKu:edit')")
    @Log(title = "色谱知识库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmSePuZhiShiKu tdmSePuZhiShiKu)
    {
        return toAjax(tdmSePuZhiShiKuService.updateTdmSePuZhiShiKu(tdmSePuZhiShiKu));
    }

    /**
     * 删除色谱知识库管理
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmSePuZhiShiKu:remove')")
    @Log(title = "色谱知识库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmSePuZhiShiKuService.deleteTdmSePuZhiShiKuByIds(ids));
    }
}
